<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/common.css" media="all">
    <link rel="stylesheet" href="../viewstyle/css/searchform.css">
    <script src="/js/layui/layui.all.js"></script>
    <script src="/admin/js/token.js"></script>
</head>

<body>
<style>
    .layui-table-cell {
        height: 100%;
        max-width: 100%;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div style="text-align: center;">
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="leibie" placeholder="输入版权类别" autocomplete="off">
                </div>

                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-admin" id="btnsearch" lay-submit
                            lay-filter="LAY-user-back-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                    </button>
                </div>
            </div>
        </div>
        <div class="layui-card-body">
            <button class="layui-btn layui-btn-sm layui-icon layui-icon-add-circle" id="add">新增版权类别</button>
            <table class="layui-table" id="table" lay-filter="demo"></table>
        </div>
    </div>
</div>
<script type="text/html" id="tb">
    <div class="layui-container">
        <span class="">版权列表</span>
    </div>
</script>

<script type="text/html" id="caozuo">

    <input type="button" id="edit" value="编辑" class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit"/>
    <a id="shouquan" class="layui-btn layui-btn-xs" lay-event="shouquan" lay-href="banquan/Shouquan.html">授权页面</a>
</script>
<script>
        var $ = layui.$
        var table = layui.table
        table.render({
            elem: '#table',
            id: 'tt',
            toolbar:"#tb",
            url: '/admin/copyright/selcopyright',
            cols: [
                [{
                    field: 'copyrightid',
                    title: '版权编号',
                    width: '20%',
                    align: 'center'
                },
                    {
                        field: 'copyrighttype',
                        title: '版权类别',
                        width: '20%',
                        align: 'center'
                    },
                    {
                        field: 'copyrightstatus',
                        title: '状态',
                        width: '20%',
                        align: 'center'
                    },
                    {
                        field: 'copyrightpicture',
                        title: '图像',
                        width: '20%',
                        templet: function (d) {
                            return "<img width='70px' height='70px' src='" + "http://127.0.0.1:8080/upload/" + d.copyrightpicture + "'></img>";
                        },
                        align: 'center'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        toolbar: '#caozuo',
                    }
                ]
            ],
            page: true
        })
            $("#add").click(function () {
                layer.open(
                    {
                        title: '新增版权',
                        content: 'AddBanquan.html',
                        type: 2,
                        area: ['100%', '100%'],
                    }
                )
            })
        //监听工具条
        table.on('tool(demo)', function (obj) {
            var getdata = obj.data;
            var tr = obj.tr;
            var layevent = obj.event;
            layui.data('banquan', {
                key: 'getdata',
                value: getdata
            });
            switch (layevent) {
                case "edit":
                    layer.open(
                        {
                            title: '编辑版权信息',
                            content: 'EditBanquan.html',
                            type: 2,
                            area: ['100%', '100%'],
                            end: function () {
                                $(".layui-laypage-btn").click();
                            }
                        }
                    )
                    break;
                case "shouquan":
                    break;
            }
        })
        $("#btnsearch").click(function () {
            table.reload('tt', {
                where: {
                    leibie: $("#leibie").val()
                },
                page: {
                    curr: 1
                }
            })
        })
        $(window).keypress(function (event) {
            if (event.which === 13) {
                $('#btnsearch').click();
            }
        })
</script>
</body>
</html>
